Log-likelihood ratio test for equality of one covariance matrix.
equal.cov(x, Sigma, a = 0.05)
A vector with the the test statistic, the p-value, the degrees of freedom and the critical value of the test.
A matrix containing Euclidean data.
The hypothesis covariance matrix.
The significance level, set to 0.05 by default.
Michail Tsagris.
R implementation and documentation: Michail Tsagris mtsagris@uoc.gr.
The hypothesis test is that the the sample covariance is equal to some specified covariance matrix: \(H_0:\pmb{\Sigma}=\pmb{\Sigma}_0\), with \(\pmb{\mu}\) unknown. The algorithm for this test is taken from Mardia, Bibby and Kent (1979, pg. 126-127). The test is based upon the log-likelihood ratio test. The form of the test is $$ -2\log{\lambda}=n \text{tr}\left\lbrace \pmb{\Sigma}_0^{-1}{\bf S}\right\rbrace-n\log{\left|\pmb{\Sigma}_0^{-1}{\bf S} \right|}-np, $$ where \(n\) is the sample size, \(\pmb{\Sigma}_0\) is the specified covariance matrix under the null hypothesis, \({\bf S}\) is the sample covariance matrix and \(p\) is the dimensionality of the data (or the number of variables). Let \(\alpha\) and \(g\) denote the arithmetic mean and the geometric mean respectively of the eigenvalues of \(\pmb{\Sigma}_0^{-1}{\bf S}\), so that \(tr\left\lbrace \pmb{\Sigma}_0^{-1}{\bf S}\right\rbrace=p\alpha\) and \(\left|\pmb{\Sigma}_0^{-1}{\bf S} \right|=g^p\), then the test statistic becomes $$ -2\log{\lambda}=np\left(\alpha-log{(g)}-1 \right). $$ The degrees of freedom of the \(\chi^2\) distribution are \(\frac{1}{2}p\left(p+1\right)\).
Mardia K.V., Kent J.T. and Bibby J.M. (1979). Multivariate Analysis. London: Academic Press.
likel.cov, Mtest.cov
x <- as.matrix( iris[, 1:4] )
s <- cov(x) * 1.5
equal.cov(x, s)
Run the code above in your browser using DataLab